<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<pre>
import math
x,y=0,0
while True:
    d = input()
    if d=="":
        break
    if d=="STOP":
        break
    moment=d.split(" ")
    dir=moment[0]
    dis=int(moment[1])
    if dir=="UP":
        y=y+dis
    elif dir=="DOWN":
        y=y-dis
    elif dir=="LEFT":
        x=x-dis
    elif dir=="RIGHT":
        x=x+dis
print('离原点的距离：',round(math.sqrt(x*x+y*y)))
    </pre>
</body>
</html>